//controlls
define(function (require, exports, module) {
    const Vue=require("vue");
    var template=require('text!./index.html');
    const api=require("api");
    const weui=require('weui');
    module.exports=Vue.extend({
        template:template,
        data:function () {
            return {
                use_bike_list:[],
                allLoaded:false
            }
        },
        created:function () {

        },
        computed:{
            isBack:function () {
                return this.$store.getters.getIsBack;
            },
            user_info:function () {
                return this.$store.getters.getUserInfo;
            }
        },
        beforeRouteEnter:function (to,from,next) {
            next(function (vm) {
                if(!vm.isBack){
                    vm.getUseBikeInfo();
                }
            })
        },
        methods:{
            getUseBikeInfo:function () {
                var v=this;
                var loading = weui.loading('loading……');
                api.useBikeInfo(1,50,v.user_info).then(function (data) {
                    if(data.user_use_bike_info&&data.user_use_bike_info.return_code==="SUCCESS"){
                        v.use_bike_list=data.user_use_bike_info.use_infos||[];
                    }else {
                        weui.topTips(data.user_use_bike_info.return_msg);
                    }
                }).catch(function (e) {
                    weui.topTips("网络异常，请刷新页面再试!");
                }).finally(function () {
                    loading.hide();
                });
            },
            loadBottom:function(id){
                console.log("loading");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                this.$refs.loadmore.onBottomLoaded(id);
            }
        }
    });
});
